<?php

class m120322_233820_add_table_prayer extends CDbMigration
{
	public $table = 'prayer';

	public function up()
	{
		$this->createTable(
			$this->table,
			array(
				'id' 			=> 'pk', // primary key, Yii'll do the rest
				'description' 	=> 'text',
				'user_id'		=> 'int unsigned not null', // this will tell Yii that this is a required field
				'status'		=> 'int default 0',
				'created_at'	=> 'datetime',
				'updated_at'	=> 'datetime'
			),
			'ENGINE=InnoDB CHARACTER SET utf8' // we need InnoDB for the indexes
		);

		$this->createIndex( 'fk_prayer_user_id', $this->table, 'user_id' );
		$this->addForeignKey('fk_prayer_user_id', $this->table, 'user_id', 'user', 'id', 'NO ACTION', 'NO ACTION');
		
	}

	public function down()
	{
		$this->dropTable( $this->table );
	}
}
